package com.dfbz.springboot_project.mapper;

import com.dfbz.springboot_project.entity.Privilege;
import org.apache.ibatis.annotations.Param;

import java.util.ArrayList;

public class RolePrivilegeProvider {
    public String InsertSelective(@Param("Rid") Integer Rid, @Param("privileges") ArrayList<Privilege> privileges){
        StringBuilder sb = new StringBuilder();
        sb.append("INSERT INTO `netctoss`.`role_privilege`(`role_id`, `privilege_id`) VALUES ");
        for (int i = 0; i < privileges.size(); i++) {
            sb.append("(#{Rid},#{privileges["+i+"].privilegeId}),");
        }
        sb.deleteCharAt(sb.length()-1);
        return sb.toString();
    }
}
